import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count:0,
    goods:[
      {
        name: '球鞋',
        id: 1,
        price: 199
      },
      {
        name: '篮球',
        id: 2,
        price: 89
      },
      {
        name: '袜子',
        id: 3,
        price: 19
      },
      {
        name: '裤子',
        id: 4,
        price: 256
      }
    ]
  },
  mutations: {
    addGoods($state,step){
     $state.goods.push(
   {
    name:step.name,
    id:$state.goods[$state.goods.length-1].id+1,
    price:step.price
   })
      },
    remoGoods($state,step){
      $state.goods=$state.goods.filter(item=>item.id !==step)
      console.log($state.goods.id=step);
      
    }
  },
  actions: {

  }
})

